<%@ page import="java.util.*" %>
<%@ page import="com.release.bean.*" %>
<%@ page import="java.sql.CallableStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.text.*" %>
<%@ page import="java.io.*" %>
<%@ page import="com.release.utils.*" %>
<%

try {
		 session = request.getSession();
			System.out.println("user_id..main" +session.getAttribute("USER_ID"));
			
//			if(false){
			if (session.getAttribute("USER_ID") == null || !((String) session.getAttribute("SESSION_ID")).equals(session.getId())) {
				try {
					response.sendRedirect("LoginPage.jsp");
				} catch (IOException ioe) {
					ioe.printStackTrace();
				}
	
			} 
			else
			{


%>

<% 
	session.setMaxInactiveInterval(7200);	// session validity for 2 hours.

	String usergroupname = (String)session.getAttribute("USER_GROUP_NAME"); 
	String userid = (String)session.getAttribute("USER_ID")==null?"":(String)session.getAttribute("USER_ID");

	
	//DBUtil dbutil = new DBUtil(getServletContext());
	DBUtil dbutil = new DBUtil();
	boolean releaseExecutionFlag = false;
	releaseExecutionFlag = dbutil.checkUserRightForRelease(userid);




%>

<HTML>
<HEAD>
<link type="text/css" rel="stylesheet" href="styles/tracker_style.css">
<TITLE>Main Page</TITLE>
<script>
function scriptL( job,server){
	document.mainPage.jobname.value=job;
	document.mainPage.servername.value=server;
	document.mainPage.editflag.value='yes';
	document.mainPage.action="addEditScript.jsp";
	document.mainPage.submit();
}

function addNewScript()
{

	
dwin = window.open("addEditScript.jsp","_self","width=840,height=665,scrollbars=yes,resizable=yes");
	
	//document.mainPage.submit();
}




function viewScript(job,server)
{
	document.mainPage.jobname.value=job;
	document.mainPage.servername.value=server;
	document.mainPage.action = "viewScript.jsp";
	//alert("job " + job);
	document.mainPage.submit();
	//dwin = window.open("viewScript.jsp","_self","width=840,height=665,scrollbars=yes,resizable=yes");
}

function valSpace(obj){
	var fs = obj.value;
		len = fs.length;
		for(i=0;len>0 && fs.indexOf(" ")==0;i++){
			fs = fs.substring(1,len-i);
		}
		if(len==i) obj.value="";
}


function trim(sString) {
   sTrimmedString = "";
   if (sString != "") {
      var iStart = 0;
      var iEnd = sString.length - 1;
      var sWhitespace = " \t\f\n\r\v";

      while (sWhitespace.indexOf(sString.charAt(iStart)) != -1) {
         iStart++;
         if (iStart > iEnd)
            break;
      }

      // If the string not just whitespace
      if (iStart <= iEnd) {
         while (sWhitespace.indexOf(sString.charAt(iEnd)) != -1)
            iEnd--;
         sTrimmedString = sString.substring(iStart,++iEnd);
      }
   }
   return sTrimmedString;
}

function search()
{
	//alert("sea");
	valSpace(document.mainPage.searchdata);
	document.mainPage.searchdata.value=trim(document.mainPage.searchdata.value);
	//alert("hii" + document.mainPage.searchtag.value); 
	if(document.mainPage.searchtag.value=="All")
	{ 
		//alert("on all");
		document.mainPage.searchallflag.value='yes';
		document.mainPage.searchdata.style.backgroundColor="#D6D6D6";
		document.mainPage.action = "mainpage.jsp";
		document.mainPage.submit();
	}
	else if(document.mainPage.searchdata.value =="")
	{alert("Search field cannot be empty");
	return false ;}
	else{
		//alert("on act");
	document.mainPage.action = "mainpage.jsp";
	document.mainPage.searchallflag.value=''
	document.mainPage.submit();
	}
}
function showTextField(){
	var stag = document.mainPage.searchtag.value;
	if(stag=='All'){
		document.mainPage.searchdata.disabled=true;
		document.mainPage.searchdata.style.backgroundColor='#EAEAEA';
	}else{
		document.mainPage.searchdata.disabled=false;
		document.mainPage.searchdata.style.backgroundColor='';
	}
}
</script>
</HEAD>

<BODY>

<FORM name="mainPage" onsubmit="javascript: return search()" action="" method="post">
<input type="hidden" name="jobname" value=" ">
<input type="hidden" name="servername" value=" ">
<input type="hidden" name="editflag" value="">
<input type="hidden" name="searchallflag" value="yes">
 
<TABLE width ="100%" border = "0">
	<TR>
		<TD colspan="2">
			<jsp:include page="HeaderNav_ReleaseObject.jsp" flush="true" />
		</TD>
	</TR>
</table>

  

<table cellpadding="0" cellspacing="1" width="60%" style="BORDER:#000000 1px solid" align=center>
	<tr bgcolor="#000077" >
		<td class=smallfonthead width=100% align=left colspan=2><b>Script Tracker (Unix Shell Scripts)</b></td>				
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td class = bodyblue align=left> <a href="ShellScriptList.jsp">Continue to Script Tracker</a></td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	
	<tr bgcolor="#000077" >
		<td class=smallfonthead width=100% align=left colspan=2><b>Release Manager</b></td>				
	</tr> 
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<!--<td class = bodyblue align=left><a href="AddReleaseDetail.jsp">Add Release Detail </a></td>-->
		<td class = bodyblue align=left><a href="AddReleaseDetail.do">Add Release Detail </a></td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td class = bodyblue align=left><a href="UpdateReleaseDetail.do">Update Release Detail </a></td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td class = bodyblue align=left><a href="ReleaseReport.do">Release Reports</a></td>
	</tr>
	
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<tr bgcolor=#EFEFEF>
	    <td>&nbsp</td>
		<td class = bodyblue align=left><a href="SupportCRDetail.jsp">CR Support Maintenance</a></td>
	</tr>
	
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
		<tr bgcolor=#EFEFEF>
	    <td>&nbsp</td>
		<td class = bodyblue align=left><a href="DataServerReport.jsp">Data Server Status Report</a></td>
	</tr>
	
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
		<tr bgcolor=#EFEFEF>
	    <td>&nbsp</td>
		<td class = bodyblue align=left><a href="ReleaseLog.jsp">View Release Logs</a></td>
	</tr>
	
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<%if(releaseExecutionFlag==true){%>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td class = bodyblue align=left><a href="ReleaseAdmin.do">Release Admin Page</a></td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<%}%>
	<tr bgcolor="#000077" >
		<td class=smallfonthead width=100% align=left colspan=2><b>Unix Shell Script Release Manager</b></td>				
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td class = bodyblue align=left> <a href="AddRelUnixScript.jsp">Add Unix Release Detail</a></td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td class = bodyblue align=left> <a href="UnixUpdateReleaseDetail.jsp">Update Unix Release Detail</a></td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td class = bodyblue align=left> <a href="UnixReleaseReport.jsp">Unix Release Reports</a></td>
	</tr>
		<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<%if(releaseExecutionFlag==true){%>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td class = bodyblue align=left> <a href="UnixReleaseAdmin.jsp">Unix Release Admin Page</a></td>
	</tr>
	<tr bgcolor=#EFEFEF>
		<td>&nbsp</td>
		<td>&nbsp</td>
	</tr>
	<%}%>
</table>


<% }
}
catch(Exception e) {
				e.printStackTrace();
		}

		%>

</FORM>
	
</BODY>

</HTML>